<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .container{
            width: 600px;
            height: 600px;
            outline: 1px solid red;
            margin:50px auto 0;
            position: relative;
        }
        
        .box{
            width: 200px;
            height: 100px;
            outline: 1px solid black;
        }
        .b1{
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
        }
        .b2{
            position: relative;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
        }
        .fl{
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .in{
            text-align: center;
            line-height: 600px;
        }
        .b4{
            display:inline-block;
        }
        .fl2{
            display: flex;
        }
        h2{
            text-align: center;
        }
        .item{
            outline: 1px solid red;
            height: 100px;
            text-align: center;
            /* width: 25%; */
            
            /* 设定项目的flex:1可以让所有项目均等的分配容器的主轴空间，而且不会应为项目的内容变化而变化大小 */
            /* flex: 1 != flex-grow:1 */
            flex: 1;
            /* 设定项目的flex-grow:1te 也可以让所有项目均等的分配容器的主轴空间，但是项目的内容变化会影响项目的整体大小 */
            /* flex-grow: 1;  */
        }
    </style>
</head>
<body>
    <!-- postion:absolute+transform 重要 -->
    <div class="container">
        <div class="box b1"></div>
    </div>
     <!-- postion:absolute+transform 元素不会脱离文档流，还会占据原来的位置 -->
    <div class="container">
        <div class="box b2"></div>
    </div>
    <!-- flex 重要 -->
    <div class="container fl">
        <div class="box b3"></div>
    </div>
    <!-- display:inline-block+text-align+line-height -->
    <div class="container in">
        <div class="box b4"></div>
    </div>
    <h2>项目的flex用法</h2>
    <div class="container fl2">
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div>
    </div>
    <div class="container fl2">
        <div class="item">itemitemit额外全额问问去请问e</div>
        <div class="item">item</div>
        <div class="item">item</div>
        <!-- <div class="item">item</div>
        <div class="item">item</div>
        <div class="item">item</div> -->
    </div>
    
</body>
</html>